#include <shmem.h>
#define N 4

static struct shm_param para;

struct student
{
    int num;
    char name[64];
};

int main(int argc, char *argv[])
{
    int ret = -1;
    int *num = NULL;
    struct student *stuaddr = NULL;

    ret = shm_init(&para, "shm_testq", sizeof(struct student)*N+4);
    if(ret < 0)
    {
        return -1;
    }
    num = shm_getaddr(&para);
    if(num == NULL)
    {
        return -1;
    }
    stuaddr = num + sizeof(int);
    if(stuaddr == NULL)
    {
        return -1;
    }
    printf("number = %d\n",*num);
    for(int i = 0;i<*num;i++)
    {
        printf("num = %d\n", stuaddr[i].num);
        printf("name = %s\n", stuaddr[i].name);
    }
    shm_del(&para);

    return 0;
}
